package com.hongdee.crm.carConfig.service;

import com.hongdee.crm.carConfig.entity.TCrmCarConf;
import com.hongdee.crm.carConfig.entity.TCrmCarConfExcelTemp;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * Created by My on 2017/5/11.
 */
public interface ITcrmCarConfService {

    /**
     * 新增车辆分配信息
     *
     * @param carConf
     * @param uid
     */
    public void saveCarConf(TCrmCarConf carConf, String uid) throws Exception;

    /**
     * 根据车辆分配规则，进行分配车辆信息
     *
     * @param confId
     * @param uid
     * @param file
     * @throws Exception
     */
    public void distCarByCarConf(String confId, String uid, MultipartFile file, String type) throws Exception;

    /**
     * @param carConf
     * @param uid
     * @throws Exception
     */
    public void editCarConf(TCrmCarConf carConf, String uid) throws Exception;

    /**
     * 检测用户在某角色下是否已经存在
     *
     * @param roleId
     * @param uid
     * @return
     */
    public boolean checkAddCarConf(String roleId, String uid, String cmpanyId) throws Exception;

    /**
     * 获得车辆分配详情
     *
     * @param id
     * @param uid
     * @return
     */
    public TCrmCarConf getCarConfigById(String id, String uid) throws Exception;

    /**
     * 查询车辆分配明细信息
     *
     * @param start
     * @param limit
     * @param roleId
     * @param userId
     * @param type
     * @param plateNum
     * @param vin
     * @return
     */
    public Map carPage(String start, String limit, String roleId, String userId, String type,
                       String plateNum, String vin, String uid) throws Exception;

    /**
     * 指定车辆分配
     *
     * @param data
     * @param roleId
     * @param uid
     */
    public void carReset(List<Map> data, String roleId, String uid, String userId) throws Exception;

    /**
     * 车辆分配规则 分页查询
     *
     * @param roleId
     * @param userId
     * @param start
     * @param limit
     * @param uid
     * @return
     */
    public Map page(String roleId, String userId, String start, String limit, String uid) throws Exception;

    /**
     * 删除车辆配置信息
     *
     * @param configId
     */
    public void removeCarConf(String configId, String uid) throws Exception;


    /**
     * 为方便切换SA查询，增加其公司ID由调用者传入，并不在通过工具获取
     * 获得其分配资源信息，生成查询sql
     *
     * @param uid
     */
    public void crmCarConfToSql(String uid, StringBuffer sqlStr, String byName, String companyId) throws Exception;

    /**
     * 读取上传的Excel信息
     *
     * @param file
     * @param uid
     * @param configId
     * @return
     * @throws IOException
     */
    public List<TCrmCarConfExcelTemp> readExcel(MultipartFile file, String uid, String configId) throws IOException;

    /**
     * 根据角色 公司ID获得该角色下的车辆分配信息
     *
     * @param roleId
     * @param companyId
     * @return
     */
    public List<TCrmCarConf> getCrmCarConfByRoleId(String roleId, String companyId) throws Exception;

    /**
     * 根据人员信息 清空人员对应的车辆配置信息
     *
     * @param uid
     * @param data
     * @throws Exception
     */
    public void emptyCarConfDetailByUid(String uid, List<Map> data) throws Exception;

    /**
     * 1、仅限尾号、尾数、未分配信息
     * 2、查询除VIN以外的分配方式；
     * 3、根据分配方式，先将分配信息清除
     * 4、在根据分配方式，将信息重新分配
     * @param uid
     */
    public void distCarByAllCarConf(String uid) throws Exception;

}
